package view

type Constant_Class struct {
	Tag       uint8
	NameIndex uint16
	Name_     Constant
}

func (self *Constant_Class) ReadConstant(cr *ClassReader) {
	self.NameIndex = cr.readUInt16(cr.readUInt8s(2))
}

func (self *Constant_Class) ReadValue(cr ClassReader, cp ConstantPoolInfo) {
	self.Name_ = cp.ConstantList[int(self.NameIndex)-1]
}

type Constant_Name_And_Type struct {
	Tag           uint8
	NameIndex     uint16
	DescribeIndex uint16
	Name_         Constant
	Describe_     Constant
}

func (self *Constant_Name_And_Type) ReadConstant(cr *ClassReader) {
	self.NameIndex = cr.readUInt16(cr.readUInt8s(2))
	self.DescribeIndex = cr.readUInt16(cr.readUInt8s(2))
}

func (self *Constant_Name_And_Type) ReadValue(cr ClassReader, cp ConstantPoolInfo) {
	self.Name_ = cp.ConstantList[int(self.NameIndex)-1]
	self.Describe_ = cp.ConstantList[int(self.DescribeIndex)-1]
}

/*
*
字段符号引用
*/
type Constant_Field_Ref struct {
	Tag              uint8
	ClassIndex       uint16
	NameAndTypeIndex uint16
	Class_           Constant
	NameAndType_     Constant
}

func (self *Constant_Field_Ref) ReadConstant(cr *ClassReader) {
	self.ClassIndex = cr.readUInt16(cr.readUInt8s(2))
	self.NameAndTypeIndex = cr.readUInt16(cr.readUInt8s(2))
}

func (self *Constant_Field_Ref) ReadValue(cr ClassReader, cp ConstantPoolInfo) {
	self.Class_ = cp.ConstantList[int(self.ClassIndex)-1]
	self.NameAndType_ = cp.ConstantList[int(self.NameAndTypeIndex)-1]
}

/*
*
普通(非接口) 方法符号引用
*/
type Constant_Method_Ref struct {
	Tag              uint8
	ClassIndex       uint16
	NameAndTypeIndex uint16
	Class_           Constant
	NameAndType_     Constant
}

func (self *Constant_Method_Ref) ReadConstant(cr *ClassReader) {
	self.ClassIndex = cr.readUInt16(cr.readUInt8s(2))
	self.NameAndTypeIndex = cr.readUInt16(cr.readUInt8s(2))
}

func (self *Constant_Method_Ref) ReadValue(cr ClassReader, cp ConstantPoolInfo) {
	self.Class_ = cp.ConstantList[int(self.ClassIndex)-1]
	self.NameAndType_ = cp.ConstantList[int(self.NameAndTypeIndex)-1]
}

/*
*
接口 方法符号引用
*/
type Constant_Interface_Method_Ref struct {
	Tag              uint8
	ClassIndex       uint16
	NameAndTypeIndex uint16
	Class_           Constant
	NameAndType_     Constant
}

type NameAndType struct {
	Name string
	Type string
}

func (self *Constant_Interface_Method_Ref) ReadConstant(cr *ClassReader) {
	self.ClassIndex = cr.readUInt16(cr.readUInt8s(2))
	self.NameAndTypeIndex = cr.readUInt16(cr.readUInt8s(2))

}

func (self *Constant_Interface_Method_Ref) ReadValue(cr ClassReader, cp ConstantPoolInfo) {
	self.Class_ = cp.ConstantList[int(self.ClassIndex)-1]
	self.NameAndType_ = cp.ConstantList[int(self.NameAndTypeIndex)-1]
}
